home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / server1.zip / _TELEFRG.QC < prev    next >
Text File  |  1996-08-30  |  2KB  |  88 lines

  1. /*
  2. **
  3. ** _telefrg.qc (Telefrag Code, 1.1)
  4. **
  5. ** Copyright (C) 1996 Johannes Plass
  6. ** 
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. ** 
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. ** 
  21. ** Author:   Johannes Plass (plass@dipmza.physik.uni-mainz.de)
  22. **
  23. */
  24.  
  25. void(entity player) TelefragInfo =
  26. {
  27.    if (!USE_MODULE_TELEFRAG) return;
  28. //                123456789#123456789#123456789#12345678
  29.    sprint(player,"# Telefrag: Reduces risk of getting\n");
  30.    sprint(player,"  telefragged by respawning players.\n");
  31. };
  32.  
  33. void(entity player) TelefragInit =
  34. {
  35.    if (!USE_MODULE_TELEFRAG) return;
  36.    // nothing to do here
  37. };
  38.  
  39. entity(entity spot) TelefragSelectSpawnPoint =
  40. {
  41.    local entity    e,firstspot;
  42.    local float search_spot;
  43.  
  44.    if (!USE_MODULE_TELEFRAG) return(spot);
  45.  
  46.    search_spot = 25;
  47.    firstspot   = spot;
  48.    //dprint("TelefragSelectSpawnPoint: for ");//#jp#(debug)
  49.    //dprint(self.netname); dprint(":");//#jp#(debug)
  50.    while (search_spot) {
  51.      e = findradius(spot.origin, 100);
  52.      if (!e) {
  53.         search_spot = 0;
  54.         //dprint(" free");//#jp#(debug)
  55.      }
  56.      else {
  57.         local float occupied;
  58.         occupied = 0;
  59.         while (!occupied && !(!e)) {
  60.           if (e.classname == "player") {
  61.              if (e.deadflag == DEAD_NO) occupied = 1;
  62.           }
  63.           else e = e.chain;
  64.         }
  65.         if (occupied) {
  66.            //dprint(" blocked");//#jp#(debug)
  67.        spot = SelectSpawnPoint ();
  68.            search_spot = search_spot - 1;
  69.            if (spot == firstspot) {
  70.               //dprint("\nback to first spot, will stop search here");//#jp#(debug)
  71.               search_spot = 0;
  72.            }
  73.         } else {
  74.            //dprint(" not-blocked");//#jp#(debug)
  75.            search_spot = 0;
  76.         }
  77.      }
  78.    }
  79.    //dprint("\n");//#jp#(debug)
  80.    return(spot);
  81. };
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.